#[macro_use]
use simple_excel_writer::*;

///写入excel
#[test]
pub fn write_excel_demo(){
    let mut wb = Workbook::create("demo.xlsx");
    let mut sheet = wb.create_sheet("my-sheet1");

    // set column width
    sheet.add_column(Column { width: 30.0 });
    sheet.add_column(Column { width: 30.0 });
    sheet.add_column(Column { width: 80.0 });
    sheet.add_column(Column { width: 60.0 });
    wb.write_sheet(&mut sheet, |sheet_writer| {
        let sw = sheet_writer;
        sw.append_row(row!["Name", "Title","Success","XML Remark"]).unwrap(); //第一行
        sw.append_row(row!["Amy", (), true,"<xml><tag>\"Hello\" & 'World'</tag></xml>"]).unwrap(); //第二行
        sw.append_blank_rows(2); //空两行
        sw.append_row(row!["Tony", blank!(2), "retired"]) // 空两格第5行
    }).expect("write excel error!");

    let mut sheet = wb.create_sheet("my-sheet2");

    wb.write_sheet(&mut sheet, |sheet_writer| {
        let sw = sheet_writer;
        sw.append_row(row!["Name", "Title","Success","Remark"]).unwrap(); //第一行
        sw.append_row(row!["Amy", "Manager", true]) //第二行
    }).expect("write excel error!");

    wb.close().expect("close excel error!");
}